package utils

import (
	"runtime"
	"time"
)

var (
	startup           time.Time = time.Now()
	minTickerInterval time.Duration
)

func init() {

	//获取一下最准确的精度
	minTickerInterval = time.Millisecond * 2
	ticker := time.NewTicker(minTickerInterval)
	start := time.Now()
	for i := 0; i < 9; i++ {
		<-ticker.C
	}
	cur := <-ticker.C
	minTickerInterval = cur.Sub(start) / time.Duration(10)

	if runtime.GOOS == "windows" {
		PathSeparator = "\\"
		cmd_exe_bin = "cmd"
	} else {
		if FileIsExists("/bin/bash") {
			cmd_exe_bin = "/bin/bash"
		} else {
			cmd_exe_bin = "/bin/sh"
		}
		PathSeparator = "/"
	}
	panicLogFilePath = "log" + PathSeparator

	RootPath, _ = GetCurrentDirectory()

	//time_def_loc, _ = time.LoadLocation("Local")
}

func StartupSeconds() float64 {
	return time.Now().Sub(startup).Seconds()
}
